package com.heima.wemedia.feign;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.apis.article.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.mapper.WmUserMapper;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.WmUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmNewsService wmNewsService;

    @Autowired
    private WmUserService wmUserService;

    @Autowired
    private WmUserMapper wmUserMapper;
    /**
     * 查询媒体审核
     * @param reqDto
     * @return
     */
    @Override
    public ResponseResult list(WmNewsPageReqDto reqDto) {
        ResponseResult reqDtolist = wmNewsService.listAll(reqDto);
        return reqDtolist;
    }

    /**
     * 用于获取自媒体端的用户名字
     * @param articleId
     * @return
     */
    @Override
    public String getName(Integer articleId) {
        WmUser wmUser = wmUserService.getById(articleId);
        String wmUserName = wmUser.getName();
        return wmUserName;
    }
}
